package cn.hashq.netpoststation.controller;

import cn.hashq.netpoststation.dto.AddClientDTO;
import cn.hashq.netpoststation.entity.Client;
import cn.hashq.netpoststation.service.ClientManagerService;
import cn.hashq.netpoststation.vo.ServerResponse;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/client")
public class ClientController {


    @Resource
    private ClientManagerService clientManagerService;

    @GetMapping("/clients")
    public ServerResponse listClient() {
        return clientManagerService.listClient();
    }

    @PutMapping("")
    public ServerResponse addClient(@RequestBody AddClientDTO dto) {
        return clientManagerService.addClient(dto);
    }

    @PostMapping("/{id}")
    public ServerResponse notifyClientStatus(@PathVariable Long id) {
        return clientManagerService.notifyClientStatus(id);
    }

    @PostMapping("")
    public ServerResponse updateClient(@RequestBody Client client) {
        return clientManagerService.updateClient(client);
    }

    @GetMapping("/detail/{id}")
    public ServerResponse getClientById(@PathVariable Long id) {
        return clientManagerService.getClientById(id);
    }

    @DeleteMapping("/{id}")
    public ServerResponse removeClient(@PathVariable Long id) {
        return clientManagerService.removeClient(id);
    }

}
